<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>课后作业1</title>
</head>
<script src="../js/vue.js"></script>

<style>
    .red {
        color: red;
    }
</style>
<body>

<div id="app">
    <ul>
        <li v-for="(item,index) in music" :class="{red:index === judgeIndex}" @click="changeColor(index)"> {{item}}</li>
    </ul>

</div>

</body>

<script>
    const vue = new Vue({
        'el': '#app',
        'data': {
            music: ['夜曲', '四面楚歌', '告白气球', '听妈妈的话'],
            judgeIndex: 0
        },
        'methods': {
            changeColor(index) {
                this.judgeIndex = index;
            }
        }
    })
</script>
</html>